<template>
<van-tabbar v-model="active" route @change="tabChange" v-if="route.meta.isTabShow" active-color="#cea62a">
  <van-tabbar-item v-for="(item,index) in tabbarItems" :key="index" :to="item.route">
    <span>{{ item.text }}</span>
    <template #icon="props">
      <img :src="props.active ? item.active : item.inactive" />
    </template>
  </van-tabbar-item>
</van-tabbar>
  <router-view/>
</template>
<script setup>
import { ref } from 'vue'
import { useRoute } from 'vue-router'
const active = ref(0)
const route = useRoute()
const tabChange = (val) => {
  active.value = val
}
const tabbarItems = ref([
  {
    text: '首页',
    route: '/home',
    active: require('./assets/icons/home-active.png'),
    inactive: require('./assets/icons/home.png')
  },
  {
    text: '专题',
    route: '/topic',
    active: require('./assets/icons/topic-active.png'),
    inactive: require('./assets/icons/topic.png')
  },
  {
    text: '分类',
    route: '/cagetory',
    active: require('./assets/icons/category-active.png'),
    inactive: require('./assets/icons/category.png')
  },
  {
    text: '购物车',
    route: '/cart',
    active: require('./assets/icons/cart-active.png'),
    inactive: require('./assets/icons/cart.png')
  },
  {
    text: '我的',
    route: '/mine',
    active: require('./assets/icons/user-active.png'),
    inactive: require('./assets/icons/user.png')
  }
])
const userInfo = {

  openId: '1231',

  nickName: '赵六',

  avatarUrl: 'https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIbWFEIJj8IpGeHM7dGic1aTFZALjWcMm9ltWfFiaQfVRYticWBfgGfzXWMt2EkJWiaicPtftHAlWxUibxQ/132'

}

const openId = userInfo.openId

localStorage.setItem('userInfo', JSON.stringify(userInfo))

localStorage.setItem('openId', openId)
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // text-align: center;
  color: #2c3e50;
  margin-bottom: 100px;
}

nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
